package com.xinya.navigationapplication.fragment

import android.os.Bundle
import android.util.Log
import android.view.View
import androidx.core.app.ActivityOptionsCompat
import androidx.navigation.ActivityNavigator
import androidx.navigation.fragment.FragmentNavigatorExtras
import androidx.navigation.fragment.findNavController
import com.xinya.navigationapplication.R
import kotlinx.android.synthetic.main.fragment_layout_login.view.*

/**
 *
 * @ClassName:      LoginFragment
 * @Description:     java类作用描述
 * @Author:         mhzhuxinya@163.com
 * @UpdateRemark:   更新说明：
 * @Version:        1.0
 */
class LoginFragment : BaseFragment() {

    companion object {
        private const val TAG = "LoginFragment"
    }

    override fun initView(rootView: View) {
        val pair1 = Pair<View, String>(rootView.imgPhoto, "userPhoto")
        // 不定参数  可以传递多个
        val extras = FragmentNavigatorExtras(pair1)

        val activityPair = androidx.core.util.Pair<View, String>(rootView.imgPhoto, "userPhoto")

        rootView.btnToForgetFragment.setOnClickListener {
            // 跳转到忘记密码页面
            findNavController().navigate(R.id.action_to_fragment_forget, null, null, extras)
        }

        rootView.btnToRegisterFragment.setOnClickListener {
            // 跳转到注册页面
            findNavController().navigate(R.id.action_to_fragment_register, null, null, extras)
        }

        rootView.btnToAgreementActivity.setOnClickListener {

            val options = ActivityOptionsCompat.makeSceneTransitionAnimation(
                requireActivity(), activityPair
            )

            val extras = ActivityNavigator.Extras.Builder()
                .setActivityOptions(options)
                .build()


            findNavController().navigate(R.id.action_to_activity_agreement, null, null, extras)
        }

        Log.d(TAG, "initView: ")
    }

    override fun getLayoutResId(): Int {
        return R.layout.fragment_layout_login
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.d(TAG, "onCreate: ")
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        Log.d(TAG, "onActivityCreated: ")
    }

    override fun onStart() {
        super.onStart()
        Log.d(TAG, "onStart: ")
    }

    override fun onResume() {
        super.onResume()
        Log.d(TAG, "onResume: ")
    }

    override fun onPause() {
        super.onPause()
        Log.d(TAG, "onPause: ")
    }

    override fun onStop() {
        super.onStop()
        Log.d(TAG, "onStop: ")
    }

    override fun onDestroyView() {
        super.onDestroyView()
        Log.d(TAG, "onDestroyView: ")
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.d(TAG, "onDestroy: ")
    }
}